<?php
// +----------------------------------------------------------------------
// | Action: 公共控制器
// +----------------------------------------------------------------------
// | Author: chen <vd8888@126.com>
// +----------------------------------------------------------------------
// |   ToDo: 暂无计划
// +----------------------------------------------------------------------
class CommonAction extends Action {

	public function _initialize() {
		/*如果agentname为空，那么说明没有登录*/
		if ($_SESSION["agent"]['username'] == "") {
			$url = U('__ROOT__/Login/login');
			redirect($url);
		}
	}

    /*
     *删除
     *@param str $table  对应数据库名
     *@param int $id     POST过来的id
     */
    public function del($table,$id){

        if(IS_POST){

            $result = M($table)->where("id=$id")->delete();

            if($result){
                $ajax['status'] = 'true';
                $ajax['Msg'] = '删除成功!';
                echo json_encode($ajax);
                die();
            }else{                
                $ajax['Msg'] = '删除失败!';
                echo json_encode($ajax);
                die();
            }
            
        }else{
            $this->error('您没有访问权限!');
        }

    }

}